<?php
//Disable notification upgrade
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );

if (function_exists('add_theme_support')) {
	add_theme_support( 'post-thumbnails' );
	set_post_thumbnail_size( 100, 100, true );
}

function sidebar_widgets_init() {
	//Left navigator
	register_sidebar( array(
		'name' => __('Left sidebar', 'cdnla' ),
		'id' => 'left_sidebar'
	) );
	//Center content
	register_sidebar( array(
		'name' => __('Center Content', 'cdnla' ),
		'id' => 'center_content'
	) );
	//Right content
	register_sidebar( array(
		'name' => __('Right sidebar', 'cdnla' ),
		'id' => 'right_sidebar'
	) );
	//Page content
	register_sidebar( array(
		'name' => __('Page sidebar', 'cdnla' ),
		'id' => 'page_content'
	) );
}
add_action( 'widgets_init', 'sidebar_widgets_init' );

function pr($arr) {
	echo "<pre>";
	print_r($arr);
	echo "</pre>";
}

function get_param($param = "", $default = "") {
	if (isset($_REQUEST[$param])) {
		return $_REQUEST[$param];
	}
	else {
		return $default;
	}
}
/* Truncate */
function truncate ($str, $length=10, $trailing='..') {
	$length-=mb_strlen($trailing);
	if (mb_strlen($str)> $length)
	{
		return mb_substr($str,0,$length).$trailing;
	}
	else
	{
		$res = $str;
	}
	return $res;
} 
/* Get first image */
function get_first_image() {
	global $post, $posts;
	$first_img = '';
	$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
	if(isset($matches[1][0])){
		$first_img = $matches [1][0];
		return $first_img;
	}  
}
?>
